package com.diy.sigmund.diyorder.common.middleware.mq.rocketmq.spring.one;

import org.apache.rocketmq.spring.annotation.ConsumeMode;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

/**
 * <br>顺序消费
 * <br>实现RocketMQListener接口
 * <br>申明泛型对象即业务对象
 * <br>使用@RocketMQMessageListener注解
 * <br>配置@RocketMQMessageListener注
 * <br>必须配置项入下
 * <br>group
 * <br>topic
 * <br>consumeMode 设为 ConsumeMode.ORDERLY
 * <br>使用@Component注解或者子注解
 * <br>实现接口方法
 *
 * @author ylm-sigmund
 * @since 2022/5/5 22:23
 */
@Component
@RocketMQMessageListener(
        topic = "${topic.syncSendOrderly}",
        consumerGroup = "${group.consumer.syncSendOrderly}",
        consumeMode = ConsumeMode.ORDERLY)
public class OrderlyConsumer implements RocketMQListener<Object> {

    private static final Logger log = LoggerFactory.getLogger(OrderlyConsumer.class);

    @Override
    public void onMessage(Object message) {
        log.info(String.format("OrderlyConsumer name is %s data is %s", this.getClass().getSimpleName(), message));
    }

}
